/**
 * VUEshop
 * ============================================================================
 * * 版权所有 2015-2027 深圳搜豹网络科技有限公司，并保留所有权利。
 * 网站地址: http://www.vueshop.com.cn
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
 * 不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
 * $Author: soubao-java 2020-07-22 $
 */<template>
  <div>
    <div style="margin-top:20px">
      <el-form :model="form" label-width="200px">
        <!-- <el-form-item label="回复类型" prop="oss_key_id">
        <el-radio-group v-model="form.msg_type">
          <el-radio label="text">文字</el-radio>
          <el-radio label="news">图文</el-radio>
        </el-radio-group>
        </el-form-item>-->
        <el-form-item label="回复内容" required>
          <el-input
            type="textarea"
            :autosize="{ minRows: 2, maxRows: 6}"
            placeholder="请输入内容"
            v-model="form.content"
            size="mini"
          ></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onSubmit()" :loading="isLoading">提 交</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
import { getAutoReply, addAutoReply, updateAutoReply } from "@/utils/api";
export default {
  data() {
    return {
      form: { type: "default", msg_type: "text" },
      isLoading: false,
      errResult: {}
    };
  },
  created() {
    this.getAutoReply();
  },
  methods: {
    getAutoReply() {
      let that = this;
      getAutoReply({ type: this.form.type }).then(res => {
        that.form = res;
      });
    },
    onSubmit() {
      let that = this;
      this.isLoading = true;
      if (this.form.id) {
        updateAutoReply(this.form).then(res => {
          if (res.status == 1) {
            that.$message.success("更新成功");
          } else {
            that.$message.error(res.msg);
          }
          that.isLoading = false;
        });
      } else {
        addAutoReply(this.form).then(res => {
          if (res.status == 1) {
            that.$message.success("保存成功");
          } else {
            that.$message.error(res.msg);
          }
          that.isLoading = false;
        });
      }
    }
  }
};
</script>

<style scoped>
>>> .el-textarea__inner {
  width: 500px;
}
</style>
